package com.xc.hotelmgr.webapi.modules.dt.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xc.hotelmgr.webapi.modules.dt.entity.PriceConfigEntity;
import com.xc.hotelmgr.webapi.modules.dt.service.PriceConfigService;
import com.xc.hotelmgr.webapi.common.utils.PageUtils;
import com.xc.hotelmgr.webapi.common.utils.R;



/**
 * 分销商加价配置
 *
 * @author kemmy
 * @email kemmy@gmail.com
 * @date 2020-09-16 14:47:32
 */
@RestController
@RequestMapping("dt/priceconfig")
public class PriceConfigController {
    @Autowired
    private PriceConfigService priceConfigService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("dt:priceconfig:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = priceConfigService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("dt:priceconfig:info")
    public R info(@PathVariable("id") Integer id){
		PriceConfigEntity priceConfig = priceConfigService.getById(id);

        return R.ok().put("priceConfig", priceConfig);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("dt:priceconfig:save")
    public R save(@RequestBody PriceConfigEntity priceConfig){
		priceConfigService.save(priceConfig);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("dt:priceconfig:update")
    public R update(@RequestBody PriceConfigEntity priceConfig){
		priceConfigService.updateById(priceConfig);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("dt:priceconfig:delete")
    public R delete(@RequestBody Integer[] ids){
		priceConfigService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
